<%@ page import="com.model.Project" %>
<%@ page import="java.util.List" %>
<%@ page import="com.model.Student" %>
<%@ page import="com.bean.ProjectUserBean" %><%--
  Created by IntelliJ IDEA.
  User: chaiyuan
  Date: 2017/5/7
  Time: 14:54
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<nav class="navbar navbar-default">
    <div class="container-fluid">
        <div class="navbar-header">
            <button type="button" class="navbar-toggle">
                <span class="sr-only">Toggle navigation</span>
                <span class="icon-bar bar1"></span>
                <span class="icon-bar bar2"></span>
                <span class="icon-bar bar3"></span>
            </button>
            <a class="navbar-brand" href="#">选择学生</a>
        </div>
        <div class="collapse navbar-collapse">

            <ul class="nav navbar-nav navbar-right">
                <li class="dropdown">
                    <a href="#" class="dropdown-toggle" data-toggle="dropdown">
                        <i class="ti-user"></i>

                        <p>您好！${sessionScope.user.name}</p>
                        <b class="caret"></b>
                    </a>
                    <ul class="dropdown-menu">
                        <li><a href="#">修改信息</a></li>
                        <li><a href="#">退出登录 </a></li>

                    </ul>
                </li>

            </ul>

        </div>
    </div>
</nav>
<div class="content">
    <div class="container-fluid">
        <div class="row">
            <div class="col-md-12">
                <div class="card">
                    <div class="header">
                        <h4 class="title">课题列表</h4>
                        <p class="category">再可选的课题前单选即可</p>
                    </div>
                    <div class="content table-responsive table-full-width">
                        <form action="/student/select" method="post">
                            <table class="table table-striped">
                                <thead>
                                <th>#</th>
                                <th>课题名称</th>
                                <th>课题简介</th>
                                <th>选择学生</th>
                                <th>状态</th>
                                <th>操作</th>
                                </thead>
                                <tbody>
                                <%

                                    List<ProjectUserBean> project = (List) request.getAttribute("list");
                                    for (int i = 0; i < project.size(); i++) {
                                %>
                                <tr>
                                    <%--<td><input type="radio" name="selected" value=<%=project.get(i).getStudent().getStr("stu_id")%>></td>--%>
                                    <td><%=i+1%>
                                    </td>
                                    <td><%=project.get(i).getProject().getStr("name")%>
                                    </td>
                                    <td><%=project.get(i).getProject().getStr("introduce")%>
                                    </td>
                                    <td><a href="javascript:void(0)"
                                           onclick=""><%=project.get(i).getStudent().getStr("name")%>
                                    </a></td>
                                        <td><%=project.get(i).getStatus()%></td>
                                    <td><a href="javascript:void(0)" onclick="onSubmit(<%=project.get(i).getStudent().getInt("stu_id")%>,<%=project.get(i).getProject().getInt("id")%>)">确认</a></td>


                                </tr>
                                <%}%>

                                </tbody>
                            </table>


                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</body>
<script type="text/javascript">
    function onSubmit(stu_id,pro_id) {
        $.ajax({
            method:"post",
            url:"/teacher/selected",
            data:{
               stu_id:stu_id,
                pro_id:pro_id
            },
            success:function () {
                alert("选择完成");
               window.location.href="/teacher";
            },

        });
    }
</script>
</html>
